<%--
  Created by IntelliJ IDEA.
  User: hongcy
  Date: 16-3-20
  Time: 下午9:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ include file="/include/taglib.jsp" %>
<div style="padding:20px 0px;">
    <form method="post" action="${ctx}/mulanweb/admin/scenic_spot/save" id="ff">
        <input type="hidden" id="scenicId" name="scenicId" value="${param.scenicId}" />
        <table cellspacing="5" style="margin: 0 auto">
            <tr>
                <td>景点名:</td>
                <td><input type="text" name="scenicName" class="easyui-textbox"
                           data-options="required:true,validType:{length:[1,50]}" style="width: 260px;" value="${param.scenicName}"/></td>
            </tr>
            <tr>
                <td>所在地点:</td>
                <td><input id="form-city" style="width: 260px;" value="${param.cityId}"/></td>
                <input type="hidden" name="cityId" id="cityId" value="${param.cityId}"/>
            </tr>
            <tr>
                <td>经度:</td>
                <td><input id="form-longitude" name="longitude" style="width: 260px;" value="${param.longitude}"/></td>
            </tr>
            <tr>
                <td>纬度:</td>
                <td><input id="form-latitude" name="latitude" style="width: 260px;" value="${param.latitude}"/></td>
            </tr>
            <tr>
                <td>详细地址:</td>
                <td><input class="easyui-textbox" data-options="required:true,valiType:{length:[1,200]}" name="position"
                           style="width: 260px;" value="${param.position}"/></td>
            </tr>
            <tr>
                <td>详情介绍:</td>
                <td><input type="text" name="description" class="easyui-textbox"
                           data-options="multiline:true,required:true,valiType:{length:[1,200]}"
                           style="width:260px;height:100px" value="${param.description}"/></td>
            </tr>
        </table>
        <p><a href="http://map.baidu.com">百度地图拾取工具</a></p>
        <p><a href="http://map.google.com" target="_blank">谷歌地图拾取工具</a></p>
        <p><a href="http://www.gpsspg.com/maps.htm" target="_blank">其他地图拾取工具</a></p>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        function queryCity() {
            $("#form-city").combobox({
                required: true,
                url: '${ctx}/mulanweb/common/city/search',
                fit: true,
                panelHeight: 200,
                valueField: 'Id',
                textField: 'NameCn',
                editable: false,
                queryParams: {
                    PageSize: 100,
                    PageNumber: 1
                },
                loadFilter: function (data) {
                    var result = [];
                    var currentSize = data.PageSize;
                    var totalSize = data.TotalRow;
                    if (data.ReturnCode == 1 && currentSize >= totalSize) {
                        if (data.DataList.length > 0) {
                            for (var tt = 0; tt < data.DataList.length; tt++) {
                                result.push({Id: data.DataList[tt].Id, NameCn: data.DataList[tt].NameCn});
                            }
                        }
                    } else {
                        Constant.showMessage("地点信息已超过最大值");
                    }
                    return result;
                }
            });
        }
        $("#form-city").combobox({
            onChange: function (newV, oldV) {
                $("#cityId").val(newV);
            }
        });
        queryCity();

        var scenicId = $("#scenicId").val();
        if(scenicId){
            $("#ff").attr("action","${ctx}/mulanweb/admin/scenic_spot/update");
        }
    })
</script>
